﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using System.Reflection;

namespace MvcWeb.EAMEnum
{
    public static class EAMEnumExt
    {
        public static List<ListItem> ToListItem<T>()
        {
            List<ListItem> li = new List<ListItem>();
            foreach (int s in Enum.GetValues(typeof(T)))
            {
                li.Add(new ListItem
                {
                    Value =  s.ToString(),
                    Text = Enum.GetName(typeof(T), s)
                }
                );
            }
            return li;
        }

        public static Dictionary<int, string> ToDictory<T>()
        {
            Dictionary<int, string> dic = new Dictionary<int, string>();
            foreach (int s in Enum.GetValues(typeof(T)))
            {
                dic.Add(int.Parse(s.ToString()), Enum.GetName(typeof(T), s)
                
                );
            }
            return dic;
        }
    }
}